'''
Created on 2009-10-22

@author: summit
'''
import wx
import wx.aui

from vtk.wx.wxVTKRenderWindowInteractor import *

class wxVTKPageView(wx.Panel):
    '''
    classdocs
    '''
    LAYOUT_NORMAL = 0
    LAYOUT_NO_3D = 1
    LAYOUT_3D_ONTOP = 2
    LAYOUT_3D_ONRIGHT = 3
    
    __viewInteractor1 = None
    __viewInteractor2 = None
    __viewInteractor3 = None
    __viewInteractor4 = None
    __layoutMode = LAYOUT_NORMAL
    __mgr = None
    
    def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, 
                 style=0, title=""):
        '''
        Constructor
        '''
        wx.Panel.__init__(self, parent)
        
        style = wx.WANTS_CHARS or wx.NO_FULL_REPAINT_ON_RESIZE
        
        self.__viewInteractor1 = wxVTKRenderWindowInteractor(self, wx.ID_ANY, style=style)
        self.__viewInteractor2 = wxVTKRenderWindowInteractor(self, wx.ID_ANY, style=style)
        self.__viewInteractor3 = wxVTKRenderWindowInteractor(self, wx.ID_ANY, style=style)
        self.__viewInteractor4 = wxVTKRenderWindowInteractor(self, wx.ID_ANY, style=style)
        self.__mgr = wx.aui.AuiManager()
        self.__mgr.SetFlags(wx.aui.AUI_MGR_RECTANGLE_HINT or wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE )
        self.__mgr.SetManagedWindow(self)
        self.DoLayout()
        
    
    def DoLayout(self):
        if self.__layoutMode == self.LAYOUT_NORMAL:
            self.__mgr.AddPane(self.__viewInteractor1, 
                               wx.aui.AuiPaneInfo().Name("Axial view").Caption("Axial View").Centre().CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor2, 
                               wx.aui.AuiPaneInfo().Name("Sagittal View").Caption("Sagittal View").Centre().Position(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor3, 
                               wx.aui.AuiPaneInfo().Name("Coronal View").Caption("Coronal View").Centre().Row(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor4, 
                               wx.aui.AuiPaneInfo().Name("3D View").Caption("3D View").Centre().Row(1).Position(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
        if self.__layoutMode == self.LAYOUT_3D_ONTOP:
            self.__mgr.AddPane(self.__viewInteractor1, 
                               wx.aui.AuiPaneInfo().Name("Axial view").Caption("Axial View").Centre().CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor2, 
                               wx.aui.AuiPaneInfo().Name("Sagittal View").Caption("Sagittal View").Centre().Row(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor3, 
                               wx.aui.AuiPaneInfo().Name("Coronal View").Caption("Coronal View").Centre().Row(2).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor4, 
                               wx.aui.AuiPaneInfo().Name("3D View").Caption("3D View").Top().CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
        if self.__layoutMode == self.LAYOUT_3D_ONRIGHT:
            self.__mgr.AddPane(self.__viewInteractor1, 
                               wx.aui.AuiPaneInfo().Name("Axial view").Caption("Axial View").Centre().Row(1).Position(0).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor2, 
                               wx.aui.AuiPaneInfo().Name("Sagittal View").Caption("Sagittal View").Centre().Row(1).Position(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor3, 
                               wx.aui.AuiPaneInfo().Name("Coronal View").Caption("Coronal View").Centre().Row(1).Position(2).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
            self.__mgr.AddPane(self.__viewInteractor4, 
                               wx.aui.AuiPaneInfo().Name("3D View").Caption("3D View").Centre().Row(1).Position(1).CloseButton(False).DestroyOnClose(False).Resizable(True).Floatable(False))
     
        self.__mgr.Update()
        
    def getLayoutMode(self):
        return self.__layoutMode


    def setLayoutMode(self, value):
        if value == self.LAYOUT_NORMAL:
            self.__mgr.GetPane(self.__viewInteractor1).Center().Row(0).Position(0)
            self.__mgr.GetPane(self.__viewInteractor2).Center().Row(0).Position(1)
            self.__mgr.GetPane(self.__viewInteractor3).Center().Row(1).Position(0)
            self.__mgr.GetPane(self.__viewInteractor4).Center().Row(1).Position(1)
        if value == self.LAYOUT_3D_ONTOP:
            self.__mgr.GetPane(self.__viewInteractor1).Center().Row(0).Position(0)
            self.__mgr.GetPane(self.__viewInteractor2).Center().Row(1).Position(0)
            self.__mgr.GetPane(self.__viewInteractor3).Center().Row(2).Position(0)
            self.__mgr.GetPane(self.__viewInteractor4).Top().Row(0).Position(0)
        if value == self.LAYOUT_3D_ONRIGHT:
            self.__mgr.GetPane(self.__viewInteractor1).Center().Row(0).Position(0)
            self.__mgr.GetPane(self.__viewInteractor2).Center().Row(0).Position(1)
            self.__mgr.GetPane(self.__viewInteractor3).Center().Row(0).Position(2)
            self.__mgr.GetPane(self.__viewInteractor4).Center().Row(1).Position(0)
        self.__mgr.Update()   
        self.__layoutMode = value


    def delLayoutMode(self):
        del self.__layoutMode


  
    def getViewInteractor1(self):
        return self.__viewInteractor1


    def getViewInteractor2(self):
        return self.__viewInteractor2


    def getViewInteractor3(self):
        return self.__viewInteractor3


    def getViewInteractor4(self):
        return self.__viewInteractor4


    def setViewInteractor1(self, value):
        self.__viewInteractor1 = value


    def setViewInteractor2(self, value):
        self.__viewInteractor2 = value


    def setViewInteractor3(self, value):
        self.__viewInteractor3 = value


    def setViewInteractor4(self, value):
        self.__viewInteractor4 = value


    def delViewInteractor1(self):
        del self.__viewInteractor1


    def delViewInteractor2(self):
        del self.__viewInteractor2


    def delViewInteractor3(self):
        del self.__viewInteractor3


    def delViewInteractor4(self):
        del self.__viewInteractor4
        
    viewInteractor1 = property(getViewInteractor1, setViewInteractor1, delViewInteractor1, "ViewInteractor1's Docstring")

    viewInteractor2 = property(getViewInteractor2, setViewInteractor2, delViewInteractor2, "ViewInteractor2's Docstring")

    viewInteractor3 = property(getViewInteractor3, setViewInteractor3, delViewInteractor3, "ViewInteractor3's Docstring")

    viewInteractor4 = property(getViewInteractor4, setViewInteractor4, delViewInteractor4, "ViewInteractor4's Docstring")

    layoutMode = property(getLayoutMode, setLayoutMode, delLayoutMode, "LayoutMode's Docstring")



    
   
        
       

if __name__=="__main__":
    app = wx.PySimpleApp()
    frame = wx.Frame(None)
    frame.panel = wxVTKPageView(frame, title="fuck")
    
    frame.Show(True)
    app.MainLoop()